FROM ubuntu:20.04
COPY Anaconda3-2024.02-1-Linux-x86_64.sh /tmp/Anaconda3-2024.02-1-Linux-x86_64.sh
COPY code/LLaMA-Factory-main /LLaMA-Factory-main
# COPY source.list /etc/apt/source.list
RUN apt update && apt install -y g++ gcc
# RUN apt-get install openssh-server -y 
# RUN apt-get install pdsh
RUN echo >> /tmp/1 || true \
    && echo q >> /tmp/1 \
    && echo yes >> /tmp/1 \
    && echo >> /tmp/1 \
    && echo yes >> /tmp/1  \
    && echo yes >> /tmp/1  \
    && chmod 755 /tmp/Anaconda3-2024.02-1-Linux-x86_64.sh
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt -y install libopenmpi-dev
RUN /tmp/Anaconda3-2024.02-1-Linux-x86_64.sh < /tmp/1 || true
RUN rm -rf /tmp/1
SHELL ["/bin/bash", "-c"]
RUN ln -s /root/anaconda3/bin/conda /bin/conda \
    && conda create -n llm-train python=3.11 -y
SHELL ["conda", "run", "-n", "llm-train", "/bin/bash", "-c"]
RUN conda init --all &&/bin/bash -c conda activate llm-train \
    && /bin/bash -c conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ \
    && /bin/bash -c conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ \
    && /bin/bash -c conda config --set show_channel_urls yes \
    && echo "conda activate llm-train" >> ~/.bashrc

RUN /bin/bash -c conda install gcc_linux-64 -y
RUN /bin/bash -c conda search -c nvidia cuda-nvcc
RUN /bin/bash -c conda install -c nvidia cuda-nvcc -y
RUN cd /LLaMA-Factory-main \
    && pip install mpi4py -i https://pypi.mirrors.ustc.edu.cn/simple \
    && pip install -e ".[torch,metrics]" -i https://pypi.mirrors.ustc.edu.cn/simple \
    && pip install deepspeed -i https://pypi.mirrors.ustc.edu.cn/simple  

ENV LANG zh_CN.UTF-8
ENV LC_ALL zh_CN.UTF-8
ENV TIME_ZONE Asia/Shanghai
